package com.bootdo.app.controller;

import com.bootdo.app.utils.AppUtilXML;
import com.bootdo.app.utils.returnresponse.ServerResponse;
import com.bootdo.appsystem.domain.OrderproductDO;
import com.bootdo.appsystem.domain.ShouruDO;
import com.bootdo.appsystem.domain.UseraccountDO;
import com.bootdo.appsystem.service.ShouruService;
import com.bootdo.common.controller.BaseController;
import com.bootdo.common.utils.PageUtils;
import com.bootdo.common.utils.Query;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 【@author 】 @fan
 * 【@Email  】 mooncluyed@outlook.com
 * 【类解释  】
 * 【@Date   】 2018/6/9 0009
 **/
@Controller
@RequestMapping("/app/shouru/")
public class AppShouruController extends BaseController {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private ShouruService shouruService;


    @GetMapping("tousershouru")
    public String toUserShouru(Integer i, Model model){
        model.addAttribute("shourucode" , i);
        return "app/my/income";
    }

    @ResponseBody
    @GetMapping("msgusershouru")
    public ServerResponse<PageUtils> msgUserShouru(@RequestParam Map<String, Object> params){
        String s = params.get("shourucode").toString();
        if(s.equals("0")){
            params.remove("shourucode");
        }
        Query query = new Query(params);
        UseraccountDO sessionCustomer = (UseraccountDO)this.getRequest().getSession().getAttribute(AppUtilXML.SESSION_CUSTOMER);
        query.put("uid" , sessionCustomer.getUid());
        List<ShouruDO> shouruDOList = shouruService.list(query);
        int total = shouruService.count(query);
        PageUtils pageUtils = new PageUtils(shouruDOList, total);
        return ServerResponse.createBySuccess(pageUtils);
    }







































}
